import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";
interface Result {
  status: number;
  msg: string;
  data: {
    list: [
      {
        learningAssessmentId: string;
        menuId: string;
        moduleId: string;
        questionType: string;
        title: string;
        answers: [
          {
            key: string;
            value: string;
          }
        ];
        trueAnswer: string;
        remark: string;
        userId: string;
        userAnswer: string;
      }
    ];
    isSubmit: boolean;
    questionNum: number;
  };
  success: boolean;
}

interface Succe {
  cmd: null;
  data: null;
  success: Boolean;
  msg: String;
  status: Number;
}

interface GetResources {
  status: 0;
  msg: String;
  data: [
    {
      url: String;
      resourceName: String;
      fileType: String;
      resourceType: Number;
      resourceId: String;
      isPreview: String;
    }
  ];
  success: true;
}
// python大数据 获取学习测评的题目列表
export const GetPythonStudyMaterial = (params: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/LearningAssessment/LoadLearningAssessment?" + params)
  );
};

// 提交学生答案
export const SubmitStuAnswer = (data: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/LearningAssessment/SubmitLearningAssessment"),
    { data }
  );
};

// 重做学习测评
export const redoStuAnswer = (params: string) => {
  return http.request<any>(
    "get",
    baseUrlApi("/LearningAssessment/ResetLearningAssessment?" + params)
  );
};

// 获取学习资源
export const GetLoadResources = (params: string) => {
  return http.request<GetResources>(
    "get",
    baseUrlApi("/LoadResources/LoadResources?" + params)
  );
};

// 提交观看记录
export const SubimtInsertRecord = (data: object) => {
  return http.request<any>("post", baseUrlApi("/LoadResources/InsertRecord"), {
    data
  });
};

//获取实验说明
export const GetDescription = (params: string) => {
  return http.request<GetResources>(
    "get",
    baseUrlApi("/TaskRemark/GetByMenuId?" + params)
  );
};

//获取代码资源 -- 加载python运行环境
export const GetLoadPythonLoadIDE = (params: string) => {
  return http.request<Succe>(
    "get",
    baseUrlApi("/LoadPython/LoadIDE?" + params)
  );
};

//检查python代码是否正确
export const LoadPythonCheckCode = (params: string) => {
  return http.request<Succe>(
    "get",
    baseUrlApi("/LoadPython/CheckCode?" + params)
  );
};

//重置
export const LoadPythonResetIDE = (params: string) => {
  return http.request<Succe>(
    "get",
    baseUrlApi("/LoadPython/ResetIDE?" + params)
  );
};
